package Distinction;

class window2 implements Runnable{

    // 设定票数
    private int tickets = 100;

    public void run(){

        while(true){
            if(tickets>0){
                System.out.println(Thread.currentThread().getName()
                        +"窗口出售了第"+tickets--+"张票");
            }
        }
    }

}

public class TicketWindow2 {

    public static void main(String[] args) {

        // 创建Runnable实现类的实例对象
        window2 tw = new window2();

        // 创建4个线程对象并启动，代表4个销售窗口
        new Thread(tw,"窗口1").start();
        new Thread(tw,"窗口2").start();
        new Thread(tw,"窗口3").start();
        new Thread(tw,"窗口4").start();

    }

}
